import { ipcMain } from "electron";
import { fileShareService } from "./service.ts";
import type { ShareFileInfo } from "@common/lan-share-types.ts";
import { lanShareServer } from "@elec/main/modules/lan-share/server.ts";

(() => {
  ipcMain.handle("lanShare.startServer", () => lanShareServer.start());
  ipcMain.handle("lanShare.stopServer", () => lanShareServer.close());
  ipcMain.handle("lanShare.getStatus", () => lanShareServer.getStatus());

  ipcMain.handle("lanShare.getSharedFiles", () => fileShareService.getSharedFileList());
  ipcMain.handle("lanShare.addShareFile", (_, file: ShareFileInfo) => fileShareService.addShareFile(file));
  ipcMain.handle("lanShare.deleteShareFile", (_, id: string) => fileShareService.deleteShareFile(id));
})();
